package com.xkdx.guangguang.fragment.shop.photo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.xkdx.guangguang.module.network.AbsModule;

public class GetPhotoCommentModule extends AbsModule {
	public PhotoComment photoComment;
	@Override
	public void parseData() throws Exception {
		backJson = (JSONArray) result;
		try {
			for (int i = 0; i < backJson.length(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("getCommentListByPhoto")) {
					photoComment = parserPhotoComment(jsonObj.getJSONObject("Content"));
				}

			}
		} catch (Exception e) {
			// TODO: handle exception
		}

	}

	// 解析照片评论
	private PhotoComment parserPhotoComment(JSONObject person) throws Exception{
		PhotoComment photoComment = new PhotoComment();
		List<PhotoCommentItem> list = new ArrayList<PhotoCommentItem>();
		try {
			if (person == null) {
				return null;
			}
			JSONObject stut = (JSONObject) person.get("Result");
			JSONObject info = (JSONObject) stut.get("DetailInfo");
			photoComment.setDataCount(info.getString("DataCount"));
			photoComment.setRefreshTime(info.getString("RefreshTime"));

			JSONArray pics = (JSONArray) stut.get("ListInfo");
			for (int j = 0; j < pics.length(); j++) {
				PhotoCommentItem item = new PhotoCommentItem();
				JSONObject pic = (JSONObject) pics.opt(j);
				item.setCommentContent(pic.getString("CommentContent"));
				item.setCommentID(pic.getString("CommentID"));
				item.setCommentType(pic.getString("CommentType"));
				item.setCreateTime(pic.getString("CreateTime"));
				item.setIsVerified(pic.getString("IsVerified"));
				item.setNickName(pic.getString("NickName"));
				item.setParentID(pic.getString("ParentID"));
				item.setPictureUrl(pic.getString("PictureUrl"));
				item.setUserAvatars(pic.getString("UserAvatars"));
				item.setUserID(pic.getString("UserID"));
				list.add(item);

			}
			photoComment.setCommentlist(list);

		} catch (Exception e) {
			throw e;
		}
		return photoComment;
	}

	public class PhotoCommentItem implements Serializable {

		String UserID;
		String NickName;
		String UserAvatars;
		String CommentID;
		String CommentType;
		String CommentContent;
		String ParentID;
		String IsVerified;
		String PictureUrl;
		String CreateTime;

		public String getUserID() {
			return UserID;
		}

		public void setUserID(String userID) {
			UserID = userID;
		}

		public String getNickName() {
			return NickName;
		}

		public void setNickName(String nickName) {
			NickName = nickName;
		}

		public String getUserAvatars() {
			return UserAvatars;
		}

		public void setUserAvatars(String userAvatars) {
			UserAvatars = userAvatars;
		}

		public String getCommentID() {
			return CommentID;
		}

		public void setCommentID(String commentID) {
			CommentID = commentID;
		}

		public String getCommentType() {
			return CommentType;
		}

		public void setCommentType(String commentType) {
			CommentType = commentType;
		}

		public String getCommentContent() {
			return CommentContent;
		}

		public void setCommentContent(String commentContent) {
			CommentContent = commentContent;
		}

		public String getParentID() {
			return ParentID;
		}

		public void setParentID(String parentID) {
			ParentID = parentID;
		}

		public String getIsVerified() {
			return IsVerified;
		}

		public void setIsVerified(String isVerified) {
			IsVerified = isVerified;
		}

		public String getPictureUrl() {
			return PictureUrl;
		}

		public void setPictureUrl(String pictureUrl) {
			PictureUrl = pictureUrl;
		}

		public String getCreateTime() {
			return CreateTime;
		}

		public void setCreateTime(String createTime) {
			CreateTime = createTime;
		}

	}

	public class PhotoComment implements Serializable {
		String DataCount;
		String RefreshTime;
		List<PhotoCommentItem> commentlist = null;

		public String getDataCount() {
			return DataCount;
		}

		public void setDataCount(String dataCount) {
			DataCount = dataCount;
		}

		public String getRefreshTime() {
			return RefreshTime;
		}

		public void setRefreshTime(String refreshTime) {
			RefreshTime = refreshTime;
		}

		public List<PhotoCommentItem> getCommentlist() {
			return commentlist;
		}

		public void setCommentlist(List<PhotoCommentItem> commentlist) {
			this.commentlist = commentlist;
		}

	}
}
